var db = require('./db');
var tool = require('../tool');
function login(username,callback)
{
    var sql='select * from login  where username='+tool.sqlstring(username)  ;

    db.dbExecuteSql(sql,function(err,value)
        {
           callback(err,value) ;
        }
    ) ;
}

function add(username, password, callback) {
    var add = 'INSERT INTO login (`username`,`password`)  VALUES ('
        + tool.sqlstring(username) + ',' + tool.sqlstring(password) + ')';
    db.dbExecuteSql(add, function (err, value) {
        if (!err) {
            callback(null, 'suess');
        }
        else {
            callback(err, null);
        }
    });
}

function addtext(name, word, callback) {
    var adds = 'INSERT INTO new_table (`name`,`textes`)  VALUES ('
        + tool.sqlstring(name) + ',' + tool.sqlstring(word) + ')';
    db.dbExecuteSql(adds, function (err, value) {
        if (!err) {
            callback(null, 'suess');
        }
        else {
            callback(err, null);
        }
    });
}
exports.login = login ;
exports.add = add;
exports.addtext = addtext;